import store from '@/store';
import { ref } from 'vue';
import { useMessage } from '@/hooks/common/useMessage';
import api from '@/api';
export const useJira = () => {
    const { createJiraLogin } = useMessage();
    const isLogin = ref<any>(false);
    // 判断是否登陆过
    const checkLogin = async (systemId) => {
        const query = {
            empId: store.getters.userInfo.employeeDTO.empId,
            systemId
        };
        const { errorCode } = await api.jiraModel.getIssuesByConditions({
            ...query
        });
        if (errorCode === '003') {
            isLogin.value = false;
            return false;
        } else {
            isLogin.value = true;
            return true;
        }
    };
    const loginJira = () => {
        return new Promise((resolve) => {
            createJiraLogin({
                onOk() {
                    isLogin.value = true;
                    resolve('');
                }
            });
        });
    };

    return {
        isLogin,
        checkLogin,
        loginJira
    };
};